#include "stdafx.h"
#include "CppUnitTest.h"

#include <HSModel/Highlighting.h>
#include <HSModel/Model3D.h>
#include <HSModel/HeightMap.h>
#include <HSModel/Ground.h>
#include <HSModel/SharedConstants.h>

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace HSModelTests
{
	TEST_CLASS(HighlightingTest)
	{
	public:
		
		TEST_METHOD(ShouldHighlightOneSquare)
		{
			HeightMap hm(2, 2);
      hm.Set(0, 0, 1);
      hm.Set(1, 0, 1);
      hm.Set(0, 1, 1);
      hm.Set(1, 1, 1);

      auto model = Highlighting::GetCellsHighlighting(hm, TVector3(0, 0, 0), 0);

      int counter = 0;
      for(auto it = model->Triangles().begin(); it != model->Triangles().end(); it++)
        counter++;

      Assert::AreEqual(2, counter);
		}
    
    TEST_METHOD(ShouldHighlightModelShouldHave4PointsAnd2Triangles)
		{
			HeightMap hm(2, 2);
      hm.Set(0, 0, 1);
      hm.Set(1, 0, 1);
      hm.Set(0, 1, 1);
      hm.Set(1, 1, 1);

      Ground ground(hm, GroundConstants::CELL_SIZE, GroundConstants::WATER_LEVEL);

      TTriangle3 picked_triangle = TTriangle3(TVector3(1, 0, 1), TVector3(0, 0, 1), TVector3(0, 1, 1));
      
      auto model = Highlighting::GetHighlightedModel(picked_triangle, ground);

      int triangle_counter = 0;
      int point_counter = 0;
      for(auto it = model->Triangles().begin(); it != model->Triangles().end(); it++)
        triangle_counter++;
      for(auto it = model->Points().begin(); it != model->Points().end(); it++)
        point_counter++;

      Assert::AreEqual(2, triangle_counter);
      Assert::AreEqual(6, point_counter);


		}
	};
}